package com.hujing.springsource.a03;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/** Bean的生命周期
 * 1. 构造函数执行
 * 2. 依赖注入
 * 3. 初始化
 * 4. 销毁
 */
@Component
public class LifeCycleBean {

    private static final Logger log =LoggerFactory.getLogger(LifeCycleBean.class);

    public LifeCycleBean(){
        log.info("构造函数执行");
    }

    @Autowired
    public void autoWired(@Value("${java_home}") String home){
        log.info("依赖注入{}",home);
    }

    @PostConstruct
    public void init(){
        log.info("初始化");
    }

    @PreDestroy
    public void destroy(){
        log.info("销毁");
    }



}
